package me.minicoral.action;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;

import me.minicoral.service.FriendService;
import me.minicoral.service.impl.FriendServiceImpl;

import com.opensymphony.xwork2.ActionSupport;

public class Friends extends ActionSupport
{
	private static final long serialVersionUID = 1L;
	
	private String fid;		//关系号
	private String fuuid;	//关注者ID
	private String cuuid;	//被关注着ID
	private String cusername;	//被关注着ID
	
	public String getFid()
	{
		return fid;
	}
	public void setFid(String fid)
	{
		this.fid = fid;
	}
	public String getFuuid()
	{
		return fuuid;
	}
	public void setFuuid(String fuuid)
	{
		this.fuuid = fuuid;
	}
	public String getCuuid()
	{
		return cuuid;
	}
	public void setCuuid(String cuuid)
	{
		this.cuuid = cuuid;
	}
	@Override
	public String toString()
	{
		return "Friends [fid=" + fid + ", fuuid=" + fuuid + ", cuuid=" + cuuid
				+ "]";
	}
	
	Map<Object, Object> dataMap = new HashMap<Object, Object>();

	public Map<Object, Object> getDataMap()
	{
		return dataMap;
	}

	private FriendService s = new FriendServiceImpl();
	
	public String addFriend()
	{
		dataMap.clear();
		dataMap.put("status", false);
		dataMap.put("message", "关注失败，请检查你的网络连接");
		setFid(UUID.randomUUID().toString());
		int i = s.addFriend(this);
		if (i == 1)
		{
			dataMap.put("status", true);
			dataMap.put("message", "关注成功");
		}
		return SUCCESS;
	}
	public String showFriend()
	{
		dataMap.clear();
		dataMap.put("status", false);
		dataMap.put("message", "关注失败，请检查你的网络连接");
		setFid(UUID.randomUUID().toString());
		List<Friends> friends = s.showFriend(this);
		return SUCCESS;
	}
}
